package com.bz.xtcx.manager.mapper;

import com.bz.xtcx.manager.entity.CmsSharePlatform;
import com.bz.xtcx.manager.mapper.provider.CmsSharePlatformProvider;
import com.bz.xtcx.manager.persist.conditions.SharePlatformCondition;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;

public interface CmsSharePlatformMapper {

	@Insert("insert into `cms_share_platform`(sp_name, sp_company, sp_domain, sp_level, sp_link, sort) "
			+ "values(#{spName, jdbcType=VARCHAR}, #{spCompany, jdbcType=VARCHAR},"
			+ "#{spDomain, jdbcType=VARCHAR},#{spLevel, jdbcType=VARCHAR},#{spLink, jdbcType=VARCHAR},#{sort})")
	int insert(CmsSharePlatform e);

	@UpdateProvider(type = CmsSharePlatformProvider.class, method = "updateByPrimaryKeySelectiveProvider")
	int updateByPrimaryKeySelective(CmsSharePlatform e);

	@SelectProvider(type = CmsSharePlatformProvider.class, method = "selectByConditionProvider")
	@Results(
            id = "cmsSharePlatformRow",
            value = {
                @Result(property = "id", column = "id"),
                @Result(property = "spName", column = "sp_name"),
                @Result(property = "spCompany", column = "sp_company"),
                @Result(property = "spDomain", column = "sp_domain"),
                @Result(property = "spLevel", column = "sp_level"),
                @Result(property = "spLink", column = "sp_link")
            }
    )
	List<CmsSharePlatform> selectByCondition(SharePlatformCondition condition);

    @SelectProvider(type = CmsSharePlatformProvider.class, method = "countByConditionProvider")
	int countByCondition(SharePlatformCondition condition);

	@Delete("delete from `cms_share_platform` where id = #{id}")
	int del(Integer id);

	@Select("select * from `cms_share_platform` where id = #{id}")
	@ResultMap("cmsSharePlatformRow")
	CmsSharePlatform findById(Integer id);
}
